var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2ADInterface = require("ADInterface");
var $2VIVOConstant = require("VIVOConstant");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_VIVOAD = /* */function (_i$default3) {
  babel_inherits(r, _i$default3);
  var _super96 = babel_createSuper(r);
  function r() {
    var _this219;
    babel_classCallCheck(this, r);
    _this219 = _super96.apply(this, arguments);
    _this219.nativeTime = 0;
    _this219.isShare = false;
    return _this219;
  }
  babel_createClass(r, [{
    key: "initAd",
    value: function initAd() {
      this.creatBanner();
      this.createVideo();
    }
  }, {
    key: "creatNative",
    value: function creatNative(e) {
      var t = qg.getSystemInfoSync().windowWidth;
      var a = qg.getSystemInfoSync().windowHeight;
      console.log("type===1", e);
      switch (e) {
        case 0:
          this.customAd1 = qg.createCustomAd({
            adUnitId: $2VIVOConstant.default.POSID_NativeAD[0],
            style: {
              left: 0,
              top: a / 2 - 720 * t / 1280 + 100
            }
          });
          this.customAd1.onError(function (e) {
            console.log("vivo原生 err:", JSON.stringify(e));
          });
      }
    }
  }, {
    key: "showNative",
    value: function showNative(e) {
      var _this220 = this;
      if (new Date().getTime() - this.nativeTime < 6e4) {
        console.log("间隔时间不足");
      } else {
        e || (e = 0);
        this.hideNative();
        this.creatNative(e);
        console.log("shownative===");
        switch (e) {
          case 0:
            this.customAd1.show().then(function () {
              console.log("原生广告加载成功");
              _this220.nativeTime = new Date().getTime();
            }).catch(function (e) {
              console.log("原生广告展示失败222:" + JSON.stringify(e));
            });
        }
      }
    }
  }, {
    key: "hideNative",
    value: function hideNative() {
      this.customAd1 && this.customAd1.destroy();
      this.customAd2 && this.customAd2.destroy();
    }
  }, {
    key: "creatInsert",
    value: function creatInsert() {
      this.insertAd = qg.createInterstitialAd({
        adUnitId: $2VIVOConstant.default.POSID_InsertAD
      });
    }
  }, {
    key: "createVideo",
    value: function createVideo() {
      this.rewardVideoAd = qg.createRewardedVideoAd({
        adUnitId: $2VIVOConstant.default.POSID_VedioAD
      });
    }
  }, {
    key: "showToast",
    value: function showToast(e) {
      qg.showToast({
        title: e
      });
    }
  }, {
    key: "showInsert",
    value: function showInsert() {
      this.creatInsert();
      var e = this;
      this.insertAd.load().then(function () {
        e.insertAd.show();
        e.log("插屏广告加载完成，准备展示");
      }).catch(function (t) {
        e.log("插屏广告异常:" + JSON.stringify(t));
        e.insertAd && e.insertAd.destroy();
      });
      this.insertAd.onError(function (t) {
        e.log("插屏广告加载出错： " + JSON.stringify(t));
        e.insertAd && e.insertAd.destroy();
      });
      this.insertAd.onClose(function (t) {
        e.log("插屏广告关闭:" + t);
        e.insertAd && e.insertAd.destroy();
      });
    }
  }, {
    key: "showVideo",
    value: function showVideo(e) {
      var _this221 = this;
      if (null != this.rewardVideoAd && null != this.rewardVideoAd) {
        this.insertIntervalTime = new Date().getTime();
        cc.game.pause();
        this.rewardVideoAd.offClose();
        this.rewardVideoAd.offError();
        this.rewardVideoAd.offLoad();
        this.rewardVideoAd.onLoad(function () {
          _this221.rewardVideoAd.show().then(function () {
            console.log("广告显示成功");
          }).catch(function (e) {
            cc.game.resume();
            console.log("广告组件出现问题", e);
          });
          console.log("视频加载成功");
        });
        this.rewardVideoAd.onError(function () {
          cc.game.resume();
        });
        this.rewardVideoAd.onClose(function (t) {
          if (t && t.isEnded || undefined === t) {
            e && e();
            _this221.showToast("奖励领取成功");
            cc.game.resume();
          } else {
            _this221.showToast("播放中途退出");
            cc.game.resume();
          }
        });
        this.rewardVideoAd.load();
      } else {
        this.createVideo();
      }
    }
  }, {
    key: "creatBanner",
    value: function creatBanner() {
      qg.getSystemInfoSync().screenWidth;
      var e = qg.getSystemInfoSync().screenHeight;
      console.log("hei==111221", e);
      this.bannerAd = qg.createBannerAd({
        adUnitId: $2VIVOConstant.default.POSID_BannerAD,
        style: {},
        adIntervals: 30
      });
      this.bannerAd.onError(function (e) {
        console.log("initBanner err:" + e);
      });
    }
  }, {
    key: "requestSubscribeSystemMessage",
    value: function requestSubscribeSystemMessage(e) {}
  }, {
    key: "onAddToFavorites",
    value: function onAddToFavorites() {}
  }, {
    key: "showBanner",
    value: function showBanner() {
      console.log("banner====");
      this.bannerAd || this.creatBanner();
      this.bannerAd.show().then(function () {
        console.log("banner加载成功");
      }).catch(function (e) {
        console.log("showBanner err:" + JSON.stringify(e));
      });
    }
  }, {
    key: "hideBanner",
    value: function hideBanner() {
      null != this.bannerAd && this.bannerAd.hide();
    }
  }, {
    key: "recorderStart",
    value: function recorderStart() {}
  }, {
    key: "recorderStop",
    value: function recorderStop() {}
  }, {
    key: "share",
    value: function share(e) {}
  }, {
    key: "canShare",
    value: function canShare() {
      return !(new Date().getTime() - this.shareTime < 3e3 || (this.shareTime = new Date().getTime(), 0));
    }
  }, {
    key: "addShortcut",
    value: function addShortcut() {}
  }, {
    key: "exitGame",
    value: function exitGame() {
      qg.exitApplication();
    }
  }, {
    key: "log",
    value: function log(e) {
      console.log("WeChatAD:" + e);
    }
  }]);
  return r;
}($2ADInterface.default);
def_VIVOAD = cc__decorate([ccp_ccclass], def_VIVOAD);
exports.default = def_VIVOAD;